<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

</head>
<body>
    <div id="app">
        <div id="app">
            <div>
                <h3>备忘录 回车保存</h3>
                <input type="text" @keyup.enter="todolist.push(todo); todo=''" v-model="todo">
                <!-- {{todolist}} -->
                <!-- ul无序，小圆点表示 -->
                <!-- ol有序，数字表示 -->
                <ol>
                    <li v-for="(item,index) in todolist" :key="index">
                        {{item}}
                        <button @click="todolist.splice(index,1)">删除</button>
                    </li>
                </ol>
                <button @click="tododelete">全部删除</button>
            </div>
        </div>
    </div>
    <script>
        new Vue({
            el:'#app',
            data:{
                todo:'',
                todolist:[],
            },
            methods:{
                tododelete(){
                    alert('确定全部删除？');
                    this.todolist=[];
            }
        }
        })
    </script>

</body>
</html>